package cn.bupt.adt.util;

import java.util.HashMap;
import java.util.Map;

/**
 * 组织发送的数据
 * 
 * @author jm E-mail:740869614@qq.com
 * @date 创建时间：2016-5-13 下午2:56:42
 * @version 1.0
 * @parameter
 * @since
 * @return
 */
public class NetDataAccessUtil {

	// 返回内容
	private Object content;
	// 结果标识符
	private int result;
	// 结果描述
	private Object resultDesp;

	public NetDataAccessUtil resultDesp(String resultDesp) {
		this.resultDesp = resultDesp;
		return this;
	}

	public NetDataAccessUtil result(int result) {
		this.result = result;
		return this;
	}
	
	public NetDataAccessUtil content(Object content) {
		this.content = content;
		return this;
	}

	public static NetDataAccessUtil success() {
		NetDataAccessUtil nau = new NetDataAccessUtil();
		nau.setResult(1);
		return nau;
	}

	public static NetDataAccessUtil error() {
		NetDataAccessUtil nau = new NetDataAccessUtil();
		nau.setResult(0);
		return nau;
	}

	public static NetDataAccessUtil error(int code) {
		NetDataAccessUtil nau = new NetDataAccessUtil();
		nau.setResult(code);
		return nau;
	}

	public Map<String, Object> generateResultSet() {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("content", this.content);
		map.put("resultDesp", this.resultDesp);
		map.put("result", this.result);
		return map;
	}

	public void setContent(Object content) {
		this.content = content;
	}

	public void setResult(int result) {
		this.result = result;
	}

	public void setResultDesp(Object resultDesp) {
		this.resultDesp = resultDesp;
	}

	public Object getContent() {
		return content;
	}

	public int getResult() {
		return result;
	}

	public Object getResultDesp() {
		return resultDesp;
	}

}
